package com.kaiyun.sharding.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.kaiyun.sharding.mapper.provide.CourseBaseProvide;
import com.kaiyun.sharding.model.CourseBase;
import com.kaiyun.sharding.model.param.Course;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 多库多表测试用Mapper
 * @author zhanNaifeng
 * @see
 * @since
 */
public interface CourseBaseMapper extends BaseMapper<CourseBase> {

    @Select("select id,name,user_id from t_course_base order by id desc")
    List<CourseBase> getList(IPage<CourseBase> page);

    @Select("select name from t_course_base where user_id=#{userId} order by id desc")
    List<Course> getList2(IPage<Course> page, Long userId);

    @SelectProvider(type = CourseBaseProvide.class, method = "getList3")
    List<Course> getList3(IPage<Course> page,Long userId);

    /**
     * 关联查询
     * @param page
     * @param base
     * @return
     */
    @SelectProvider(type = CourseBaseProvide.class, method = "getList4")
    List<Course> getList4(IPage<Course> page,CourseBase base);

    @Update(" update t_course_base set user_id=#{userId} where id=#{id}")
    int updateCourseBase(Long userId,Long id);
}
